/********************************************
 * 功能说明: 
 * 模块名称: 
 * 系统名称: 
 * 软件版权: Frank
 * 系统版本: 1.0.0
 * 开发人员: Frank
 * 开发时间: 2019/9/19 15:35
 * 审核人员: 
 * 相关文档: 
 * 修改记录: 修改日期 修改人员 修改说明
 *********************************************/
package com.spring.arch.job.model;

import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * 任务日志
 * @author Frank
 * @version 1.0.0.1
 * @since JDK 1.8
 */
@NoArgsConstructor
@Getter
@Setter
@Entity
@Table(name = "xxl_job_log")
public class JobLog implements Serializable {

    private static final long serialVersionUID = -5038927277974153792L;
    /**
     * 主键id
     */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(nullable = false, unique = true, insertable = false, updatable = false)
    private Long id;

    /**
     * 执行器主键ID
     */
    @NotNull
    @Column(name = "job_group")
    private Integer jobGroup;

    /**
     * 任务主键ID
     */
    @NotNull
    @Column(name = "job_id")
    private Integer jobId;

    /**
     * 执行器地址，本次执行的地址
     */
    @Size(max = 255)
    @Column(name = "executor_address")
    private String executorAddress;

    /**
     * 执行器任务handler
     */
    @Size(max = 255)
    @Column(name = "executor_handler")
    private String executorHandler;

    /**
     * 执行器任务参数
     */
    @Size(max = 512)
    @Column(name = "executor_param")
    private String executorParam;

    /**
     * 执行器任务分片参数，格式如 1/2
     */
    @Size(max = 20)
    @Column(name = "executor_sharding_param")
    private String executorShardingParam;

    /**
     * 失败重试次数
     */
    @NotNull
    @Column(name = "executor_fail_retry_count", columnDefinition = "int(11) NOT NULL DEFAULT '0' COMMENT '失败重试次数'")
    private int executorFailRetryCount = 0;

    /**
     * 调度-时间
     */
    @Column(name = "trigger_time")
    private LocalDateTime triggerTime;

    /**
     * 调度-结果
     */
    @Column(name = "trigger_code")
    private int triggerCode;

    /**
     * 调度-日志
     */
    @Column(name = "trigger_msg", columnDefinition = "text COMMENT '调度-日志'")
    private String triggerMsg;

    /**
     * 执行-时间
     */
    @Column(name = "handle_time")
    private LocalDateTime handleTime;

    /**
     * 执行-状态
     */
    @NotNull
    @Column(name = "handle_code")
    private int handleCode;

    /**
     * 执行-日志
     */
    @Column(name = "handle_msg", columnDefinition = "text COMMENT '执行-日志'")
    private String handleMsg;

    /**
     * 告警状态：0-默认、1-无需告警、2-告警成功、3-告警失败
     */
    @Column(name = "alarm_status", columnDefinition = "tinyint(4) NOT NULL DEFAULT '0' COMMENT '告警状态：0-默认、1-无需告警、2-告警成功、3-告警失败'")
    private int alarmStatus = 0;
}
